home *** CD-ROM | disk | FTP | other *** search
/ Acorn RISC PD-CD 1 / Acorn RISC PD-CD 1.iso / languages / dde / _pc / h / wimp < prev    next >
Encoding:
Text File  |  1992-04-30  |  35.6 KB  |  936 lines

  1. (* Title:   wimp.h
  2.  * Purpose: C interface to RISC OS Wimp routines.
  3.  *     
  4.  *)
  5.  
  6. # ifndef __wimp_h
  7. # define __wimp_h
  8.  
  9. # ifndef __os_h
  10. # include "os.h"
  11. # endif
  12.  
  13. # ifndef __sprite_h
  14. # include "sprite.h"
  15. # endif
  16.  
  17. const
  18.   wimp_WMOVEABLE = $00000002;     (* is moveable *)
  19.   wimp_REDRAW_OK = $00000010;     (* can be redrawn entirely by wimp
  20.                                    * ie. no user graphics *)
  21.   wimp_WPANE     = $00000020;     (* window is stuck over tool window *)
  22.   wimp_WTRESPASS = $00000040;     (* window is allowed to go outside
  23.                                    * main area *)
  24.   wimp_WSCROLL_R1= $00000100;     (* scroll request returned when
  25.                                    * scroll button clicked- auto repeat*)
  26.   wimp_SCROLL_R2 = $00000200;     (* as SCROLL_R1, debounced, no auto *)
  27.   wimp_REAL_COLOURS = $000000400; (* use real window colours. *)
  28.   wimp_BACK_WINDOW = $000000800;  (* this window is a background window. *)
  29.   wimp_HOT_KEYS = $000001000;     (* generate events for 'hot keys' *)
  30.  
  31.   wimp_WOPEN  = $00010000;        (* window is open *)
  32.   wimp_WTOP   = $00020000;        (* window is on top (not covered) *)
  33.   wimp_WFULL  = $00040000;        (* window is full size *)
  34.   wimp_WCLICK_TOGGLE = $00080000; (* open_window_request was due to click
  35.                                    * on toggle-size button *)
  36.   wimp_WFOCUS = $00100000;        (* window has input focus *) 
  37.  
  38.   wimp_WBACK  = $01000000;        (* window has back button *)
  39.   wimp_WQUIT  = $02000000;        (* has a quit button *)
  40.   wimp_WTITLE = $04000000;        (* has a title bar *)
  41.   wimp_WTOGGLE= $08000000;        (* has a toggle-size button *)
  42.   wimp_WVSCR  = $10000000;        (* has vertical scroll bar *)
  43.   wimp_WSIZE  = $20000000;        (* has size box *)
  44.   wimp_WHSCR  = $40000000;        (* has horizontal scroll bar *)
  45.   wimp_WNEW   = $80000000;        (* use these new flags *)
  46.                                   (* NB! always set the WNEW flag *)
  47.  
  48. type wimp_wflags_pre = ^wimp_wflags;
  49.      wimp_wflags = integer;
  50.  
  51. const
  52.   wimp_WCTITLEFORE = 0;
  53.   wimp_WCTITLEBACK = 1;
  54.   wimp_WCWKAREAFORE = 2;
  55.   wimp_WCWKAREABACK = 3;
  56.   wimp_WCSCROLLOUTER = 4;
  57.   wimp_WCSCROLLINNER = 5;
  58.   wimp_WCTITLEHI = 6;
  59.   wimp_WCRESERVED = 7;
  60.  
  61. type wimp_wcolours_ptr = ^wimp_wcolours;
  62.      wimp_wcolours = integer;
  63.  
  64. (* If work area background is 255 then it isn't painted. *)
  65. (* If title foreground is 255 then you get no borders, title etc. at all *)
  66.  
  67. const
  68.   wimp_ITEXT      = $00000001;     (* icon contains text *)
  69.   wimp_ISPRITE    = $00000002;     (* icon is a sprite *)
  70.   wimp_IBORDER    = $00000004;     (* icon has a border *)
  71.   wimp_IHCENTRE   = $00000008;     (* text is horizontally centred *)
  72.   wimp_IVCENTRE   = $00000010;     (* text is vertically centred *)
  73.   wimp_IFILLED    = $00000020;     (* icon has a filled background *)
  74.   wimp_IFONT      = $00000040;     (* text is an anti-aliased font *)
  75.   wimp_IREDRAW    = $00000080;     (* redraw needs application's help *)
  76.   wimp_INDIRECT   = $00000100;     (* icon data is 'indirected' *)
  77.   wimp_IRJUST     = $00000200;     (* text right justified in box *)
  78.   wimp_IESG_NOC   = $00000400;     (* if selected by right button; don't
  79.                                     * cancel other icons in same ESG *)
  80.   wimp_IHALVESPRITE=$00000800;     (* plot sprites half-size *)
  81. (* Must use #define because of type wimp_ibtype *)
  82. #define wimp_IBTYPE $00001000      (* 4-bit field: button type *)
  83.   wimp_ISELECTED  = $00200000;     (* icon selected by user (inverted) *)
  84.   wimp_INOSELECT  = $00400000;     (* icon cannot be selected (shaded) *)
  85.   wimp_IDELETED   = $00800000;     (* icon has been deleted *)
  86.   wimp_IFORECOL   = $01000000;     (* 4-bit field: foreground colour *)
  87.   wimp_IBACKCOL   = $10000000;     (* 4-bit field: background colour *)
  88.  
  89. type wimp_iconflags_ptr = ^wimp_iconflags;
  90.      wimp_iconflags = integer;
  91.  
  92. (* If the icon contains anti-aliased text then the colour fields
  93. give the font handle: *)
  94.  
  95. const wimp_IFONTH = $01000000;
  96.  
  97. const
  98.   wimp_BIGNORE = 0;               (* ignore all mouse ops *)
  99.   wimp_BNOTIFY = 1;
  100.   wimp_BCLICKAUTO = 2;
  101.   wimp_BCLICKDEBOUNCE = 3;
  102.   wimp_BSELREL = 4;
  103.   wimp_BSELDOUBLE = 5;
  104.   wimp_BDEBOUNCEDRAG = 6;
  105.   wimp_BRELEASEDRAG = 7;
  106.   wimp_BDOUBLEDRAG = 8;
  107.   wimp_BSELNOTIFY = 9;
  108.   wimp_BCLICKDRAGDOUBLE = 10;
  109.   wimp_BCLICKSEL = 11;            (* useful for on/off and radio buttons *)
  110.   wimp_BWRITABLE = 15;
  111.  
  112. type wimp_ibtype_ptr = ^wimp_ibtype;
  113.      wimp_ibtype = integer;
  114.  
  115. const
  116.   wimp_BRIGHT       = $001;
  117.   wimp_BMID         = $002;
  118.   wimp_BLEFT        = $004;
  119.   wimp_BDRAGRIGHT   = $010;
  120.   wimp_BDRAGLEFT    = $040;
  121.   wimp_BCLICKRIGHT  = $100;
  122.   wimp_BCLICKLEFT   = $400;
  123.  
  124. type wimp_bbits_ptr = ^wimp_bbits;
  125.      wimp_bbits = integer;
  126.  
  127. const
  128.   wimp_MOVE_WIND = 1;                 (* change position of window *)
  129.   wimp_SIZE_WIND = 2;                 (* change size of window *)
  130.   wimp_DRAG_HBAR = 3;                 (* drag horizontal scroll bar *)
  131.   wimp_DRAG_VBAR = 4;                 (* drag vertical scroll bar *)
  132.   wimp_USER_FIXED = 5;                (* user drag box - fixed size *)
  133.   wimp_USER_RUBBER = 6;               (* user drag box - rubber box *)
  134.   wimp_USER_HIDDEN = 7;               (* user drag box - invisible box *)
  135.  
  136. type wimp_dragtype_ptr = ^wimp_dragtype;
  137.      wimp_dragtype = integer;
  138.  
  139. (**************************************************************************)
  140.  
  141. type wimp_w_ptr = ^wimp_w;
  142.      wimp_w = integer; (* abstract window handle *)
  143.      wimp_i_ptr = ^wimp_i;
  144.      wimp_i = integer; (* abstract icon handle *)
  145.      wimp_t_ptr = ^wimp_t;
  146.      wimp_t = integer; (* abstract task handle *)
  147.  
  148. type wimp_icondata_tag = 1..4;
  149.      wimp_icondata_ptr = ^wimp_icondata;
  150.      wimp_icondata =
  151.        record
  152.          case wimp_icondata_tag of
  153.            1 : (text : packed array[1..11] of char);
  154.                           (* up to 12 bytes of text *)
  155.            2 : (sprite_name : packed array[1..11] of char);
  156.                           (* up to 12 bytes of sprite name *)
  157.            3 : (indirectsprite :
  158.                   record
  159.                     name : string;
  160.                     spritearea : pointer;
  161.                           (* 0->use the common sprite area *)
  162.                           (* 1->use the wimp sprite area *)
  163.                     nameisname : integer
  164.                           (* if FALSE, name is in fact a sprite pointer. *)
  165.                   end);
  166.            4 : (indirecttext :
  167.                   record
  168.                     buffer : string;
  169.                           (* pointer to text buffer *)
  170.                     validstring : string;
  171.                           (* pointer to validation string *)
  172.                     bufflen : integer
  173.                           (* length of text buffer *)
  174.                   end);
  175.        end;
  176.  
  177. type wimp_box_ptr = ^wimp_box;
  178.      wimp_box =
  179.        record
  180.          x0, y0, x1, y1 : integer
  181.        end;
  182.  
  183. type wimp_wind_ptr = ^wimp_wind;
  184.      wimp_wind =
  185.        record
  186.          box : wimp_box;       (* screen coords of work area *)
  187.          scx, scy : integer;   (* scroll bar positions *)
  188.          behind : wimp_w;      (* handle to open window behind, -1 if top *)
  189.          flags : wimp_wflags;  (* word of flag bits defined above *)
  190.          colours : array[0..7] of byte;
  191.                                (* colours: index using wimp_wcolours. *)
  192.          ex : wimp_box;        (* maximum extent of work area *)
  193.          titleflags : wimp_iconflags;  (* icon flags for title bar *)
  194.          workflags : wimp_iconflags;   (* just button type relevant *)
  195.          spritearea : pointer; (* 0->use the common sprite area *)
  196.                                (* 1->use the wimp sprite area *)
  197.          minsize : integer;    (* two 16-bit OS-unit fields, (width/height)
  198.                                   giving min size of window. 0->use title. *)
  199.          title : wimp_icondata;(* title icon data *)
  200.          nicons : integer      (* no. of icons in window *)
  201.        end;
  202. (* If there are any icon definitions, they should follow this record
  203.    immediately in memory. *)
  204.  
  205. type wimp_winfo_ptr = ^wimp_winfo;
  206.      wimp_winfo =         (* result of get_info call. *)
  207.        record
  208.          w : wimp_w;
  209.          info : wimp_wind;
  210.        end;
  211. (* Space for icons must follow. *)
  212.  
  213. type wimp_icon_ptr = ^wimp_icon;
  214.      wimp_icon =                  (* icon description structure *)
  215.        record
  216.          box : wimp_box;          (* bounding box - relative to
  217.                                    * window origin (work area top left) *)
  218.          flags : wimp_iconflags;  (* word of flag bits defined above *)
  219.          data : wimp_icondata     (* union of bits & bobs as above *)
  220.        end;
  221.  
  222. type wimp_icreate_ptr = ^wimp_icreate;
  223.      wimp_icreate =               (* structure for creating icons. *)
  224.        record
  225.          w : wimp_w;
  226.          i : wimp_icon
  227.        end;
  228.  
  229. type wimp_openstr_ptr = ^wimp_openstr;
  230.      wimp_openstr =
  231.        record
  232.          w : wimp_w;      (* window handle *)
  233.          box : wimp_box;  (* position on screen of visible work area *)
  234.          x, y : integer;  (* 'real' coordinates of visible work area *)
  235.          behind : wimp_w  (* handle of window to go behind (-1 = top,
  236.                            * -2 = bottom) *)
  237.        end;
  238.  
  239. type wimp_wstate_ptr = ^wimp_wstate;
  240.      wimp_wstate =        (* result for window state enquiry *)
  241.        record
  242.          o : wimp_openstr;
  243.          flags : wimp_wflags
  244.        end;
  245.  
  246. const                    (* event types *)
  247.   wimp_ENULL = 0;        (* null event *)
  248.   wimp_EREDRAW = 1;      (* redraw event *)
  249.   wimp_EOPEN = 2;
  250.   wimp_ECLOSE = 3;
  251.   wimp_EPTRLEAVE = 4;
  252.   wimp_EPTRENTER = 5;
  253.   wimp_EBUT = 6;         (* mouse button change *)
  254.   wimp_EUSERDRAG = 7;
  255.   wimp_EKEY = 8;
  256.   wimp_EMENU = 9;
  257.   wimp_ESCROLL = 10;
  258.   wimp_ELOSECARET = 11;
  259.   wimp_EGAINCARET = 12;
  260.   wimp_ESEND = 17;       (* send message, don't worry if it doesn't arrive *)
  261.   wimp_ESENDWANTACK = 18;(* send message, return ack if not acknowledged *)
  262.   wimp_EACK = 19;        (* acknowledge receipt of message. *)
  263.  
  264. type wimp_etype_ptr = ^wimp_etype;
  265.      wimp_etype = integer;
  266.  
  267. const               (* event type masks *)
  268.   wimp_EMNULL        = shl(1, wimp_ENULL);
  269.   wimp_EMREDRAW      = shl(1, wimp_EREDRAW);
  270.   wimp_EMOPEN        = shl(1, wimp_EOPEN);
  271.   wimp_EMCLOSE       = shl(1, wimp_ECLOSE);
  272.   wimp_EMPTRLEAVE    = shl(1, wimp_EPTRLEAVE);
  273.   wimp_EMPTRENTER    = shl(1, wimp_EPTRENTER);
  274.   wimp_EMBUT         = shl(1, wimp_EBUT);
  275.   wimp_EMUSERDRAG    = shl(1, wimp_EUSERDRAG);
  276.   wimp_EMKEY         = shl(1, wimp_EKEY);
  277.   wimp_EMMENU        = shl(1, wimp_EMENU);
  278.   wimp_EMSCROLL      = shl(1, wimp_ESCROLL);
  279.   wimp_EMLOSECARET   = shl(1, wimp_ELOSECARET);
  280.   wimp_EMGAINCARET   = shl(1, wimp_EGAINCARET);
  281.   wimp_EMSEND        = shl(1, wimp_ESEND);
  282.   wimp_EMSENDWANTACK = shl(1, wimp_ESENDWANTACK);
  283.   wimp_EMACK         = shl(1, wimp_EACK);
  284.  
  285. type wimp_emask_ptr = ^wimp_emask;
  286.      wimp_emask = integer;
  287.  
  288. type wimp_redrawstr_ptr = ^wimp_redrawstr;
  289.      wimp_redrawstr =
  290.        record
  291.          w : wimp_w;
  292.          box : wimp_box;     (* work area coordinates *)
  293.          scx, scy : integer; (* scroll bar positions *)
  294.          g : wimp_box        (* current graphics window *)
  295.        end;
  296.  
  297. type wimp_mousestr_ptr = ^wimp_mousestr;
  298.      wimp_mousestr =
  299.        record
  300.          x, y : integer;     (* mouse x and y *)
  301.          bbits : wimp_bbits; (* button state *)
  302.          w : wimp_w;         (* window handle, or -1 if none *)
  303.          i : wimp_i          (* icon handle, or -1 if none *)
  304.        end;
  305.  
  306. type wimp_caretstr_ptr = ^wimp_caretstr;
  307.      wimp_caretstr =
  308.        record
  309.          w : wimp_w;
  310.          i : wimp_i;
  311.          x, y : integer;   (* offset relative to window origin *)
  312.          height : integer; (* -1 if calc within icon
  313.                             * bit 24 -> VDU-5 type caret
  314.                             * bit 25 -> caret invisible
  315.                             * bit 26 -> bits 16..23 contain colour
  316.                             * bit 27 -> colour is "real" colour *)
  317.          index : integer   (* position within icon *)
  318.        end;
  319.  
  320. (* Message action codes are allocated just like SWI codes. *)
  321. const
  322.   wimp_MCLOSEDOWN    = 0; (* Reply if any dialogue with the user is required,
  323.                              and the closedown sequence will be aborted. *)
  324.   wimp_MDATASAVE     = 1; (* request to identify directory *)
  325.   wimp_MDATASAVEOK   = 2; (* reply to message type 1 *)
  326.   wimp_MDATALOAD     = 3; (* request to load/insert dragged icon *)
  327.   wimp_MDATALOADOK   = 4; (* reply that file has been loaded *)
  328.   wimp_MDATAOPEN     = 5; (* warning that an object is to be opened *)
  329.   wimp_MRAMFETCH     = 6; (* transfer data to buffer in my workspace *)
  330.   wimp_MRAMTRANSMIT  = 7; (* I have transferred some data to a buffer in your
  331.                              workspace *)
  332.   wimp_MPREQUIT      = 8;
  333.   wimp_PALETTECHANGE = 9;
  334.   wimp_SAVEDESK      = 10; (* Wimp 3.00 onwards, desktop closedown message *)
  335.   wimp_MDEVICECLAIM  = 11; (* Broadcast before an application can claim
  336.                             * parallel port, RS232 port etc. *)
  337.   wimp_MDEVICEINUSE  = 12; (* Reply if another application is already
  338.                             * using the device *)
  339.   wimp_MDATASAVED    = 13; (* A file previously saved has become 'safe' *)
  340.  
  341.   wimp_FilerOpenDir  = $0400;
  342.   wimp_FilerCloseDir = $0401;
  343.  
  344.   wimp_Notify        = $40040;  (* net filer notify broadcast *)
  345.  
  346.   wimp_MMENUWARN     = $400c0;
  347.   (* menu warning. Sent if wimp_MSUBLINKMSG set. Data sent is:
  348.          submenu field of relevant wimp_menuitem.
  349.          screen x-coord
  350.          screen y-coord
  351.          list of menu selection indices (0..n-1 for each menu)
  352.          terminating -1 word.
  353.      Typical response is to call wimp_create_submenu.
  354.   *)
  355.   wimp_MMODECHANGE   = $400c1;
  356.   wimp_MINITTASK     = $400c2;
  357.   wimp_MCLOSETASK    = $400c3;
  358.   wimp_MSLOTCHANGE   = $400c4;       (* Slot size has altered *)
  359.   wimp_MSETSLOT      = $400c5;       (* Task manager requests application
  360.                                          to change its slot size *)
  361.   wimp_MTASKNAMERQ   = $400c6;       (* Request task name *)
  362.   wimp_MTASKNAMEIS   = $400c7;       (* Reply to task name request *)
  363.   wimp_MTASKSTARTED  = $400c8;       (* Broadcast by task to indicate that
  364.                                       * it has now fully started *)
  365.  
  366.   wimp_MHELPREQUEST  = $502;         (* interactive help request *)
  367.   wimp_MHELPREPLY    = $503;         (* interactive help message *)
  368.  
  369.   (* Messages for dialogue with printer applications *)
  370.  
  371.   wimp_MPrintFile       = $80140;    (* Printer app's first response to *)
  372.                                      (* a DATASAVE *)
  373.   wimp_MWillPrint       = $80141;    (* Acknowledgement of PrintFile *)
  374.   wimp_MPrintTypeOdd    = $80145;    (* Broadcast when strange files *)
  375.                                      (* dropped on the printer *)
  376.   wimp_MPrintTypeKnown  = $80146;    (* Ack to above *)
  377.   wimp_MPrinterChange   = $80147;    (* New printer application installed *)
  378.  
  379. type wimp_msgaction_ptr = ^wimp_msgaction;
  380.      wimp_msgaction = integer;
  381.  
  382. type wimp_msghdr_ptr = ^wimp_msghdr;
  383.      wimp_msghdr =           (* message block header. *)
  384.        record
  385.          size : integer;     (* 20<=size<=256, multiple of 4 *)
  386.          task : wimp_t;      (* task handle of sender (filled in by wimp) *)
  387.          my_ref : integer;   (* unique ref number (filled in by wimp) *)
  388.          your_ref : integer; (* (0==>none) if non-zero, acknowledge *)
  389.          action : wimp_msgaction  (* message action code *)
  390.        end;
  391. (* size is the size of the whole msgstr, see below. *)
  392.  
  393. type wimp_msgdatasave_ptr = ^wimp_msgdatasave;
  394.      wimp_msgdatasave =
  395.        record
  396.          w : wimp_w;  (* window in which save occurs. *)
  397.          i : wimp_i;  (* icon there *)
  398.          x : integer; (* position within window of destination of save. *)
  399.          y : integer;
  400.          estsize : integer;    (* estimated size of data, in bytes *)
  401.          _type : integer;      (* file type of data to save *)
  402.          leaf : packed array[1..11] of char
  403.                       (* proposed leaf-name of file, 0-terminated *)
  404.        end;
  405.  
  406. type wimp_msgdatasaveok_ptr = ^wimp_msgdatasaveok;
  407.      wimp_msgdatasaveok =
  408.        record
  409. (* w, i, x, y, estsize, type copied unaltered from DataSave message. *)
  410.          w : wimp_w;  (* window in which save occurs. *)
  411.          i : wimp_i;  (* icon there *)
  412.          x : integer; (* position within window of destination of save. *)
  413.          y : integer;
  414.          estsize : integer;    (* estimated size of data, in bytes *)
  415.          _type : integer;      (* file type of data to save *)
  416.          name : packed array[1..211] of char
  417.                       (* the name of the file to save *)
  418.        end;
  419.  
  420. type wimp_msgdataload_ptr = ^wimp_msgdataload;
  421.      wimp_msgdataload =
  422.        record
  423.          w : wimp_w;      (* target window *)
  424.          i : wimp_i;      (* target icon *)
  425.          x : integer;     (* target coords in target window work area *)
  426.          y : integer;
  427.          size : integer;  (* must be 0 *)
  428.          _type : integer; (* type of file *)
  429.          name : packed array[1..211] of char
  430.                           (* the filename follows. *)
  431.        end;
  432.  
  433. (* for a data load reply, no arguments are required. *)
  434.  
  435. type wimp_msgdataopen_ptr = ^wimp_msgdataopen;
  436.      wimp_msgdataopen = wimp_msgdataload;
  437. (* The data provided when opening a file is exactly the same. the
  438.  * window, x, y refer to the bottom lh corner of the icon that represents
  439.  * the file being opened, or w=-1 if there is no such. *)
  440.  
  441. type wimp_msgramfetch_ptr = ^wimp_msgramfetch;
  442.      wimp_msgramfetch =      (* transfer data in memory *)
  443.        record
  444.          addr : string;      (* address of data to transfer *)
  445.          nbytes : integer    (* number of bytes to transfer *)
  446.        end;
  447.  
  448. type wimp_msgramtransmit_ptr = ^wimp_msgramtransmit;
  449.      wimp_msgramtransmit =       (* I have transferred some data to a
  450.                                   * buffer in your workspace *)
  451.        record
  452.          addr : string;          (* copy of value sent in RAMfetch *)
  453.          nbyteswritten : integer (* number of bytes written *)
  454.        end;
  455.  
  456. type wimp_msgsavedesk_ptr = ^wimp_msgsavedesk;
  457.      wimp_msgsavedesk =       (* Save state for restart *)
  458.        record
  459.          filehandle : integer (* RISC OS file handle (not a C one!) *)
  460.        end;
  461.  
  462. type wimp_msgdevice_ptr = ^wimp_msgdevice;
  463.      wimp_msgdevice =
  464.        record
  465.          major : integer;     (* Major device number *)
  466.          minor : integer;     (* Minor device number *)
  467.          information : packed array[1..227] of char
  468.                               (* Null-terminated information string *)
  469.        end;
  470.  
  471. type wimp_msghelprequest_ptr = ^wimp_msghelprequest;
  472.      wimp_msghelprequest =
  473.        record
  474.          m : wimp_mousestr    (* where the help is required *)
  475.        end;
  476.  
  477. type wimp_msghelpreply_ptr = ^wimp_msghelpreply;
  478.      wimp_msghelpreply =
  479.        record
  480.          text : packed array[1..199] of char;  (* the helpful string *)
  481.        end;
  482.  
  483. type wimp_msgprint_ptr = ^wimp_msgprint;
  484.      wimp_msgprint =     (* structure used in all print messages *)
  485.        record
  486.          filler : array[0..4] of integer;
  487.          _type : integer;                    (* filetype *)
  488.          name : packed array[1..211] of char (* filename *)
  489.        end;
  490.  
  491. type wimp_msgstr_tag = 0..12;
  492.      wimp_msgstr_ptr = ^wimp_msgstr;
  493.      wimp_msgstr =       (* message block *)
  494.        record
  495.          hdr : wimp_msghdr;
  496.          case wimp_msgstr_tag of
  497.            0 : (chars : array[0..235] of byte);
  498.            1 : (words : array[0..58] of integer); (* max data size. *)
  499.            2 : (datasave : wimp_msgdatasave);
  500.            3 : (datasaveok : wimp_msgdatasaveok);
  501.            4 : (dataload : wimp_msgdataload);
  502.            5 : (dataopen : wimp_msgdataopen);
  503.            6 : (ramfetch : wimp_msgramfetch);
  504.            7 : (ramtransmit : wimp_msgramtransmit);
  505.            8 : (helprequest : wimp_msghelprequest);
  506.            9 : (helpreply : wimp_msghelpreply);
  507.           10 : (print : wimp_msgprint);
  508.           11 : (savedesk : wimp_msgsavedesk);
  509.           12 : (device : wimp_msgdevice)
  510.        end;
  511.  
  512. type wimp_eventdata_tag = 0..7;
  513.      wimp_eventdata_ptr = ^wimp_eventdata;
  514.      wimp_eventdata =
  515.        record
  516.          case wimp_eventdata_tag of
  517.            0 : (o : wimp_openstr);
  518.                             (* for redraw, close, enter, leave events *)
  519.            1 : (but :
  520.                   record    (* for button change event *)
  521.                     m : wimp_mousestr;
  522.                     b : wimp_bbits
  523.                   end);
  524.            2 : (dragbox : wimp_box); (* for user drag box event *)
  525.            3 : (key :
  526.                   record    (* for key events *)
  527.                     c : wimp_caretstr;
  528.                     chcode : integer
  529.                   end);
  530.            4 : (menu : array[0..9] of integer);
  531.                             (* for menu event: terminated by -1 *)
  532.            5 : (scroll :
  533.                   record    (* for scroll requests *)
  534.                     o : wimp_openstr;
  535.                     x : integer;     (* x=-1 for left, +1 for right *)
  536.                     y : integer      (* y=-1 for down, +1 for up    *)
  537.                   end);     (* scroll by +/-2 -> page scroll request *)
  538.            6 : (c : wimp_caretstr);  (* for caret gain/lose. *)
  539.            7 : (msg : wimp_msgstr)   (* for messages. *)
  540.        end;
  541.  
  542. type wimp_eventstr_ptr = ^wimp_eventstr;
  543.      wimp_eventstr =           (* wimp event description *)
  544.        record
  545.          e : wimp_etype;       (* event type *)
  546.          data : wimp_eventdata
  547.        end;
  548.  
  549. type wimp_menuhdr_ptr = ^wimp_menuhdr;
  550.      wimp_menuhdr =
  551.        record
  552.          title : packed array[1..11] of char;  (* menu title (optional) *)
  553.          tit_fcol, tit_bcol, work_fcol, work_bcol : byte;    (* colours *)
  554.          width, height : integer;   (* size of following menu items *)
  555.          gap : integer              (* vertical gap between items *)
  556.        end;
  557.  
  558. const          (* menu item flag set *)
  559.   wimp_MTICK       = 1;
  560.   wimp_MSEPARATE   = 2;
  561.   wimp_MWRITABLE   = 4;
  562.   wimp_MSUBLINKMSG = 8; (* show a => flag, and inform program when it
  563.                            is activated. *)
  564.   wimp_MLAST = $80;     (* signal last item in the menu *)
  565.  
  566. type wimp_menuflags_ptr = ^wimp_menuflags;
  567.      wimp_menuflags = integer;
  568. (* use wimp_INOSELECT to shade the item as unselectable,
  569.  * and the button type to mark it as writable. *)
  570.  
  571. type wimp_menustr_ptr = ^wimp_menustr;
  572. (* Only for the circular reference in menuitem/str. *)
  573.  
  574.      wimp_menuitem_ptr = ^wimp_menuitem;
  575.      wimp_menuitem =
  576.        record
  577.          flags : wimp_menuflags;     (* menu entry flags *)
  578.          submenu : wimp_menustr_ptr; (* wimp_menustr* pointer to sub menu,
  579.                                       * or wimp_w dialogue box,
  580.                                       * or -1 if no submenu *)
  581.          iconflags : wimp_iconflags; (* icon flags for the entry *)
  582.          data : wimp_icondata        (* icon data for the entry *)
  583.        end;
  584. (* submenu can also be a wimp_w, in which case the window is opened as a
  585.  * dialogue box within the menu tree. *)
  586.  
  587.      wimp_menustr =
  588.        record
  589.          hdr : wimp_menuhdr
  590.          (* item : array[] of wimp_menuitem *)
  591.          (* Zero or more menu items follow in memory *)
  592.        end;
  593.  
  594. type wimp_dragstr_ptr = ^wimp_dragstr;
  595.      wimp_dragstr =
  596.        record
  597.          window : wimp_w;
  598.          _type : wimp_dragtype;
  599.          box : wimp_box;          (* initial position for drag box *)
  600.          parent : wimp_box        (* parent box for drag box *)
  601.        end;
  602.  
  603. type wimp_which_block_ptr = ^wimp_which_block;
  604.      wimp_which_block =
  605.        record
  606.          window : wimp_w;        (* handle *)
  607.          bit_mask : integer;     (* bit set => consider this bit *)
  608.          bit_set : integer       (* desired bit setting *)
  609.        end;
  610.  
  611. type wimp_pshapestr_ptr = ^wimp_pshapestr;
  612.      wimp_pshapestr =
  613.        record
  614.          shape_num : integer; (* pointer shape number (0 turn off pointer) *)
  615.          shape_data : string; (* shape data, NULL pointer implies existing
  616.                                * shape *)
  617.          width : integer;     (* Width and height in pixels. Width = 4 * n,
  618.          height : integer;     * where n is an integer. *)
  619.          activex : integer;   (* active point (pixels from top left) *)
  620.          activey : integer
  621.        end;
  622.  
  623. type wimp_font_array_ptr = ^wimp_font_array;
  624.      wimp_font_array =            (* initialise all to zero before using for *)
  625.        record                     (* first load_template, then just use *)
  626.           f : array[0..255] of byte(* repeatedly without altering *)
  627.        end;
  628.  
  629. type wimp_template_ptr = ^wimp_template;
  630.      wimp_template =          (* template reading structure *)
  631.        record
  632.          reserved : integer;  (* ignore - implementation detail *)
  633.          buf : wimp_wind_ptr; (* pointer to space for putting template in *)
  634.          work_free : ^byte;   (* pointer to start of free wimp workspace -
  635.                                * you have to provide the wimp system with
  636.                                * workspace to store its redirected icons in*)
  637.          work_end : ^byte;    (* end of workspace you are offering to wimp *)
  638.          font : wimp_font_array_ptr;
  639.                               (* points to font reference count array, 0
  640.                                * pointer implies fonts not allowed *)
  641.          name : string;       (* name to match with (can be wildcarded) *)
  642.          index : integer      (* pos. in index to search from (0 = start) *)
  643.        end;
  644.  
  645. type wimp_paletteword_tag = 0..1;
  646.      wimp_paletteword_ptr = ^wimp_paletteword;
  647.      wimp_paletteword =
  648.        record
  649.          case wimp_paletteword_tag of
  650.            0 : (bytes :
  651.                   record
  652.                     gcol, red, green, blue : byte
  653.                   end);
  654.            1 : (word : integer)
  655.        end;
  656.  
  657. (* The gcol char (least significant) is a gcol colour except in 8-bpp
  658.  * modes, when bits 0..2 are the tint and bits 3..7 are the gcol colour. *)
  659.  
  660. type wimp_palettestr_ptr = ^wimp_palettestr;
  661.      wimp_palettestr =
  662.        record
  663.          c : array[0..15] of wimp_paletteword; (* wimp colours 0..15 *)
  664.          screenborder, mouse1, mouse2, mouse3 : wimp_paletteword
  665.        end;
  666.  
  667. (**************************************************************************)
  668.  
  669. procedure wimp_initialise(var v : integer) : error; extern;
  670. (* Close & delete all windows, return wimp version number. *)
  671.  
  672. procedure wimp_taskinit(name : string;
  673.                 var version : integer;
  674.                 var t : wimp_t) : error; extern;
  675. (* Name is the name of the program. *)
  676. (* Used instead of wimp_initialise. Returns your task handle. *)
  677. (* Version should be at least 200 on entry, and will return the
  678.  * current wimp version number. *)
  679.  
  680. procedure wimp_create_wind(w : wimp_wind_ptr;
  681.                 var handle : wimp_w) : error; extern;
  682. (* define (but not display) window, return window handle *)
  683.  
  684. procedure wimp_create_icon(ic : wimp_icreate_ptr;
  685.                 var result : wimp_i) : error; extern;
  686. (* add icon definition to that of window, return icon handle *)
  687.  
  688. procedure wimp_delete_wind(w : wimp_w) : error; extern;
  689.  
  690. procedure wimp_delete_icon(w : wimp_w; i : wimp_i) : error; extern;
  691.  
  692. procedure wimp_open_wind(o : wimp_openstr_ptr) : error; extern;
  693. (* make window appear on screen *)
  694.  
  695. procedure wimp_close_wind(w : wimp_w) : error; extern;
  696. (* Remove from active list the window with handle in integer argument. *)
  697.  
  698. procedure wimp_poll(make : wimp_emask;
  699.                 result : wimp_eventstr_ptr) : error; extern;
  700. (* Poll next event from the WIMP *)
  701.  
  702. procedure wimp_save_fp_state_on_poll; extern;
  703. (* Activates saving of floating point state on calls to wimp_poll
  704.  * and wimp_pollidle; this is needed if you do any floating point at
  705.  * all, as other programs may corrupt the FP status word, which is
  706.  * effectively a global in your program
  707.  *)
  708.  
  709. procedure wimp_corrupt_fp_state_on_poll; extern;
  710. (* Disables saving of floating point state on calls to wimp_poll
  711.  * and wimp_pollidle; use only if you never use FP at all
  712.  *)
  713.  
  714. procedure wimp_redraw_wind(r : wimp_redrawstr_ptr;
  715.                 var out : integer) : error; extern;
  716. (* Draw window outline and icons. Return FALSE if there's nothing to draw. *)
  717.  
  718. procedure wimp_update_wind(r : wimp_redrawstr_ptr;
  719.                 var out : integer) : error; extern;
  720. (* Return visible portion of window. Return FALSE if nothing to redraw. *)
  721.  
  722. procedure wimp_get_rectangle(r : wimp_redrawstr_ptr;
  723.                 var out : integer) : error; extern;
  724. (* return next rectangle in list, or FALSE if done. *)
  725.  
  726. procedure wimp_get_wind_state(w : wimp_w;
  727.                 result : wimp_wstate_ptr) : error; extern;
  728. (* read current window state *)
  729.  
  730. procedure wimp_get_wind_info(result : wimp_winfo_ptr) : error; extern;
  731. (* On entry result->w gives the window in question. Space for any
  732.  * icons must follow *result. *)
  733.  
  734. procedure wimp_set_icon_state(w : wimp_w; i : wimp_i;
  735.                 value, mask : wimp_iconflags) : error; extern;
  736. (* Set icon's flags as (old_state & ~mask) ^ value *)
  737.  
  738. procedure wimp_get_icon_info(w : wimp_w; i : wimp_i;
  739.                 result : wimp_icon_ptr) : error; extern;
  740. (* Get current state of icon *)
  741.  
  742. procedure wimp_get_point_info(
  743.                 result : wimp_mousestr_ptr) : error; extern;
  744. (* Give info regarding the state of the mouse *)
  745.  
  746. procedure wimp_drag_box(d : wimp_dragstr_ptr) : error; extern;
  747. (* start the wimp dragging a box *)
  748.  
  749. procedure wimp_force_redraw(r : wimp_redrawstr_ptr) : error; extern;
  750. (* Mark an area of the screen as invalid.
  751.  * If r->wimp_w == -1 then use screen coordinates. Only the first
  752.  * five fields of r are valid. *)
  753.  
  754. procedure wimp_set_caret_pos(c : wimp_caretstr_ptr) : error; extern;
  755. (* set pos./size of text caret *)
  756.  
  757. procedure wimp_get_caret_pos(c : wimp_caretstr_ptr) : error; extern;
  758. (* get pos./size of text caret *)
  759.  
  760. procedure wimp_create_menu(m : wimp_menustr_ptr;
  761.                 x, y : integer) : error; extern;
  762. (* 'pop up' menu structure. Set m==(wimp_menustr_ptr)-1 to clear the
  763.  * menu tree. *)
  764.  
  765. type wimp_menuselection_ptr = ^wimp_menuselection;
  766.      wimp_menuselection = integer;
  767.  
  768. procedure wimp_decode_menu(m : wimp_menustr_ptr;
  769.                 selections : wimp_menuselection_ptr;
  770.                 s : string) : error; extern;
  771.  
  772. procedure wimp_which_icon(b : wimp_which_block_ptr;
  773.                 results : wimp_i_ptr) : error; extern;
  774. (* The results appear in an array, terminated by a (wimp_i) -1. *)
  775.  
  776. procedure wimp_set_extent(r : wimp_redrawstr_ptr) : error; extern;
  777. (* Alter extent of a window's work area - only handle and 1st set of
  778.  * 4 coordinates are looked at. *)
  779.  
  780. procedure wimp_set_point_shape(
  781.                 p : wimp_pshapestr_ptr) : error; extern;
  782. (* set pointer shape on screen *)
  783.  
  784. procedure wimp_open_template(name : string) : error; extern;
  785. (* opens named file to allow load_template to
  786.  * read a template from the file. *)
  787.  
  788. procedure wimp_close_template : error; extern;
  789. (* close currently open template file *)
  790.  
  791. procedure wimp_load_template(t : wimp_template_ptr) : error; extern;
  792. (* load a window template from open file into buffer *)
  793.  
  794. procedure wimp_processkey(chcode : integer) : error; extern;
  795. (* Hand back to the wimp a key that you do not understand. *)
  796.  
  797. procedure wimp_closedown : error; extern;
  798.  
  799. procedure wimp_taskclose(t : wimp_t) : error; extern;
  800. (* Calls closedown in the multi-tasking form. *)
  801.  
  802. procedure wimp_starttask(clicmd : string) : error; extern;
  803. (* Start a new wimp task, with the given CLI command. *)
  804.  
  805. procedure wimp_getwindowoutline(
  806.                 r : wimp_redrawstr_ptr) : error; extern;
  807. (* set r->w on entry. On exit, r->box will be the screen coordinates
  808.  * of the window, including border, title, scroll bars. *)
  809.  
  810. procedure wimp_pollidle(mask : wimp_emask;
  811.                 result : wimp_eventstr_ptr;
  812.                 earliest : integer) : error; extern;
  813. (* Like wimp_poll, but do not return before earliest return time.
  814.  * This is a value produced by OS_ReadMonotonicTime. *)
  815.  
  816. procedure wimp_ploticon(i : wimp_icon_ptr) : error; extern;
  817. (* Called only within update or redraw loop. Just does the plotting,
  818. this need not be a real icon attached to a window. *)
  819.  
  820. procedure wimp_setmode(mode : integer) : error; extern;
  821. (* Set the screen mode. Palette colours are maintained, if possible. *)
  822.  
  823. procedure wimp_readpalette(p : wimp_palettestr_ptr) : error; extern;
  824.  
  825. procedure wimp_setpalette(p : wimp_palettestr_ptr) : error; extern;
  826. (* The bytes.gcol values of each field of the palettestr are ignored,
  827.  * only the absolute colours are taken into account. *)
  828.  
  829. procedure wimp_setcolour(colour : integer) : error; extern;
  830. (* bits 0..3 = wimp colour (translate for current mode)
  831.         4..6 = gcol action
  832.         7    = foreground/background.
  833. *)
  834.  
  835. procedure wimp_spriteop(reason_code : integer;
  836.                 name : string) : error; extern;
  837. (* call SWI Wimp_SpriteOp *)
  838.  
  839. procedure wimp_spriteop_full(regs : os_regset_ptr) : error; extern;
  840. (* call SWI Wimp_SpriteOp allowing full information to be passed *)
  841.  
  842. function wimp_baseofsprites : pointer; extern;
  843. (* Returns a sprite_area*. This may be moved about by mergespritefile. *)
  844.  
  845. procedure wimp_blockcopy(w : wimp_w;
  846.                 source : wimp_box_ptr;
  847.                 x, y : integer) : error; extern;
  848. (* Copy the source box (defined in window coords) to the given destination
  849. (in window coords). Invalidate any portions of the destination that cannot be
  850. updated using on-screen copy. *)
  851.  
  852. const
  853.   wimp_EOK       = 1;        (* put in "OK" box *)
  854.   wimp_ECANCEL   = 2;        (* put in "CANCEL" box *)
  855.   wimp_EHICANCEL = 4;        (* highlight CANCEL rather than OK. *)
  856. (* If OK and CANCEL are both 0 you get an OK. *)
  857.  
  858. type wimp_errflags_ptr = ^wimp_errflags;
  859.      wimp_errflags = integer;
  860.  
  861. procedure wimp_reporterror(err : error;
  862.                 flags : wimp_errflags;
  863.                 name : string) : error; extern;
  864. (* Produces an error window. Uses sprite called "error" in the wimp sprite
  865.  * pool. name should be the program name, appearing after "error in " at the
  866.  * head of the dialogue box. *)
  867.  
  868. procedure wimp_sendmessage(code : wimp_etype;
  869.                 msg : wimp_msgstr_ptr;
  870.                 dest : wimp_t) : error; extern;
  871. (* dest can also be 0, in which case the message is sent to every task in
  872.  * turn, including the sender. msg can also be any other wimp_eventdata*
  873.  * value. *)
  874.  
  875. procedure wimp_sendwmessage(code : wimp_etype;
  876.                 msg : wimp_msgstr_ptr;
  877.                 w : wimp_w;
  878.                 i : wimp_i) : error; extern;
  879. (* Send a message to the owner of a specific window/icon. msg can also be
  880.  * any other wimp_eventdata* value. *)
  881.  
  882. procedure wimp_create_submenu(sub : wimp_menustr_ptr;
  883.                 x, y : integer) : error; extern;
  884. (* sub can also be a wimp_w, in which case it is opened by the wimp
  885.  * as a dialogue box. *)
  886.  
  887. procedure wimp_slotsize(var currentslot : integer;
  888.                 var nextslot : integer;
  889.                 var freepool : integer) : error; extern;
  890. (* currentslot/nextslot==-1 -> just read setting. *)
  891.  
  892. procedure wimp_transferblock(sourcetask : wimp_t;
  893.                 sourcebuf : pointer;
  894.                 desttask : wimp_t;
  895.                 destbuf : pointer;
  896.                 buflen : integer) : error; extern;
  897. (* Transfer memory between domains. *)
  898.  
  899. procedure wimp_setfontcolours(foreground,
  900.                 background : integer) : error; extern;
  901. (* Set font manager colours. The wimp handles how many shades etc. to use. *)
  902.  
  903. procedure wimp_readpixtrans(area : sprite_area_ptr;
  904.                 id : sprite_id_ptr;
  905.                 factors : sprite_factors_ptr;
  906.                 pixtrans : sprite_pixtrans_ptr) : error; extern;
  907. (* Tells you how the WIMP will plot a sprite when asked to PutSpriteScaled *)
  908.  
  909. const
  910.   wimp_command_TITLE = 0;
  911.   wimp_command_ACTIVE = 1;
  912.   wimp_command_CLOSE_PROMPT = 2;
  913.   wimp_command_CLOSE_NOPROMPT = 3;
  914.  
  915. type wimp_command_tag = integer;
  916.  
  917. type wimp_commandwind_ptr = ^wimp_commandwind;
  918.      wimp_commandwind =
  919.        record
  920.          tag : wimp_command_tag;
  921.          title : string
  922.        end;
  923.  
  924. procedure wimp_commandwindow(
  925.                 commandwindow : wimp_commandwind) : error; extern;
  926. (* Open a text window for normal VDU 4-type output
  927.    Note:  the tag types correspond to the 4 kinds of call to
  928.    SWI wimp_CommandWindow shown in the Programmer's Ref Manual.
  929.    Title is only required if tag == wimp_command_TITLE.
  930.    It is the application's responsibility to set the tag correctly.
  931.  *)
  932.  
  933. # endif
  934.  
  935. (* end wimp.h *)
  936.